<template>
	<view class="content">
<!-- :style="[{backgroundImage:'url(' + comApi+'crmebimage/public/maintain/2023/11/27/0823dd23e7f24377b525fb90c457cecfknxokpyest.png' + ')' }]" -->
		<view class="index-head"
			>
			<!-- <navbar title="共富认养"
				background="linear-gradient(179deg, #1EAB80 0%, rgba(30,171,128,0.469) 39%, rgba(255,255,255,0) 100%);">
				<view class="head-left" @click="getLocationBtn">

					<view class="head-left-up">{{lacationCity}}</view>
					<view class="head-left-down">
						
						{{weatherData}}
					</view>
				</view>

			</navbar> -->

			<view class="index-serch">
				<view class="head-left" @click="getLocationBtn">

					<view class="head-left-up">{{lacationCity}}</view>
					<view class="head-left-down">

						{{weatherData}}
					</view>
				</view>

				<view class="index-serch-left">
					<view class="index-serch-left-left" @click="goPage('/pages/goods_search/index')">
						<text class='iconfont icon-sousuo2'></text>
						<input type="text" disabled placeholder="搜索您想要购买的商品" />
					</view>
					<!-- <view class="index-serch-left-right">
						<text>搜索</text>

					</view> -->


				</view>
				<view class="index-serch-right" @click="goPage('/pagesA/consult/news')">
					<image src="@/static/index/icon_xx.png" mode="scaleToFill"></image>

				</view>
				<!-- <view class="index-serch-right"
					style="display: flex;align-items: center;text-align: center;justify-content: center;"
					@click="sys()">
					<image style="width: 60rpx;height: 60rpx;"
						:src="comApi+'crmebimage/public/content/2024/03/07/icon_sys1.png'" mode="scaleToFill">
					</image>
				</view> -->
			</view>
			<view class="index-banner">
				<swiper class="swiper" style="line-height: 100px;" :indicator-dots="true"
					indicator-active-color='#ffffff' :circular="true" :autoplay="true" :interval="3000"
					:duration="1000">
					<swiper-item v-for="(item,index) in imgUrls">
						<view class="swiper-item" @click="goPage(item.url,item.type)">
							<image :src="item.pic" mode="scaleToFill"></image>
						</view>
					</swiper-item>

				</swiper>
			</view>

		</view>
		<view class="index-wrap">
			<view class="index-wrap-msg">

				<!-- 公告 -->

				<view class='notice'>

					<view class="pic">
						<!-- <image src="../../static/index/icon——gf.png" mode="aspectFit"></image> -->

						<image
							:src="comApi+'crmebimage/public/maintain/2024/03/25/549a4175adf64bd58cd798a0e408f1dcn9gYaq7ceT.png'"
							mode="aspectFit"></image>
						<!-- <image src="/static/images/xinjian.png"></image> -->
					</view>

					<view class='swipers'>
						<swiper :indicator-dots="indicatorDots" :autoplay="autoplay" interval="2400" duration="400"
							vertical="true" circular="true">
							<block v-for="(item,index) in roll" :key='index'>
								<swiper-item>
									<view class="dis" style="margin-top: 15rpx;" @click="goPage(item.url,item.type)">
										<view class="notice-tag">新闻</view>
										<view class="notice-msg">
											{{item.info}}
										</view>
									</view>


								</swiper-item>
							</block>
						</swiper>
						<swiper :indicator-dots="indicatorDots" :autoplay="autoplay" interval="2500" duration="500"
							vertical="true" circular="true">
							<block v-for="(item,index) in roll2" :key='index'>
								<swiper-item>
									<view class="dis" style="margin-top: 15rpx;" @click="goPage(item.url,item.type)">
										<view class="notice-tag">动态</view>
										<view class="notice-msg">
											{{item.info}}
										</view>
									</view>



								</swiper-item>
							</block>
						</swiper>
					</view>
					<view class="iconfont icon-xiangyou" @click="goPage('/pages/news_list/index')"></view>
				</view>

				<view class="" style="background: #fff;padding: 0 24rpx;">
					<!-- 介绍 -->
					<view class="getRich-des">
						<view class="getRich-des-left" v-for="(item,index) in descTxtList" @click="goPage(item.url)">
							<image style="width:100%;height:100%;border-radius: 20rpx;" :src="item.image"
								mode="aspectFit"></image>
						</view>


					</view>
					<!-- 菜单栏 -->
					<view class="index-menu">
						<view class="index-menu-msg" v-for="(item,index) in menus" :key="index"
							@click="goPage(item.url)">

							<image :src="item.pic" mode="aspectFit"></image>
							<text>{{item.name}}</text>

							<!-- <image src="../../static/index/icon_cgyy.png" mode=""></image> -->

						</view>
					</view>
					<view class="index-coupon" v-if="couponList.length!=0">
						<scroll-view scroll-x="true" class="index-coupon-view">
							<view class="index-coupon-msg" :style="{backgroundImage:'url('+coutBj+')'}"
								v-for="(item,index) in couponList" :key="index">
								<view class="index-coupon-msg-wrap">
									<view class="index-coupon-msg-left">
										<view class="index-coupon-msg-left-up">{{item.money}}</view>
										<view class="index-coupon-msg-left-bom">满{{item.minPrice}}可用</view>
									</view>

									<view class="index-coupon-msg-center">
										<view class="index-coupon-msg-center-up">{{item.name}}</view>
										<view class="index-coupon-msg-center-bom">
											{{item.useRangeStr}}
										</view>
									</view>

									<view class="index-coupon-msg-bom" v-if="item.isUse==true"
										@click="goPage(`/pagesA/associatedCoupons/index?couponId=${item.id}`)">
										去使用
									</view>
									<view class=" index-coupon-msg-bom"
										@click="goPage('/pages/users/user_get_coupon/index')" v-else>
										待领取
									</view>
								</view>

							</view>
						</scroll-view>
					</view>

					<!-- 热门认养 -->
					<view class="com-tit" v-if="hotAdoptionPackageList.length!=0">
						<view>热门认养</view>
						<view @click='goPage("/pagesA/comProsperity/index")'>
							<image src="@/static/com/icon_more.png" mode=""></image>
						</view>
					</view>
					<view class="index-foster" v-if="hotAdoptionPackageList.length!=0">
						<!-- hotAdoptionPackageList -->
						<fosterList :bastList="hotAdoptionPackageList" type="2"></fosterList>

					</view>
					<view class="com-banner">
						<swiper class="swiper" indicator-active-color='#ffffff' circular :indicator-dots="true"
							:autoplay="true" interval="2000" duration="1000">
							<swiper-item v-for="(item,index) in bannerList" :key="index">
								<image :src="item.pic" @click="goPage(item.url,item.type)" mode=""></image>
							</swiper-item>

						</swiper>
					</view>




					<view class="com-tit" v-if="hotActivityInfoList&&hotActivityInfoList.length!=0">
						<view>热门活动</view>
						<view>
							<image @click="goPage('/pagesA/childStudy/index')" src="@/static/com/icon_more.png" mode="">
							</image>
						</view>
					</view>
					<view class="" v-if="hotActivityInfoList&&hotActivityInfoList.length!=0">
						<hotList :hotList="hotActivityInfoList"></hotList>
					</view>
					<view class="com-tit">
						<view>数字农业实时数据</view>
						<view>
							<!-- <image src="@/static/com/icon_more.png" mode=""></image> -->
						</view>
					</view>
					<view class="index-realTime">
						<view class="realTime-msg dis" v-for="(item,index) in nowTimeList">
							<view class="realTime-msg-left ">
								<view class="secondaryColour">{{item.label}}</view>
								<view class="realTime-msg-left-bom secondaryColour">{{item.value}}</view>
							</view>
							<view class="realTime-msg-right">
								<image :src="item.pic" mode="widthFix"></image>
							</view>
						</view>
					</view>
					<view class="ding">

					</view>
				</view>

			</view>

		</view>
		<!-- 新闻简报 -->
		<uni-popup ref="inputDialog" type="dialog">
			<!-- @confirm="dialogConfirm" -->
			<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="授权定位" title="开启定位"
				content="开启小程序定位授权后，我们将为您推荐就近门店" @confirm="dialogConfirm"></uni-popup-dialog>
		</uni-popup>
		<uni-popup ref="giftPup" type="dialog">
			<view class="gift-wrap">
				<swiper style="height: 100%;" :indicator-dots="true" :circular="true" :autoplay="true" :interval="3000"
					:duration="1000">
					<swiper-item v-for="(item,indesx) in gift" :key="indesx" @click="goPage(item.url)">
						<view class="" style=" height: 100%;">
							<image :src="item.image" mode="aspectFill" style="border-radius: 20rpx;"></image>
						</view>

					</swiper-item>

				</swiper>
				<!-- <view class="gift-msg">
					<view class="gift-msg-left">新人送
						<text class="gift-msg-left-num">200元</text>
					</view>
					<view class="gift-msg-right">认养优惠券</view>
				</view> -->
				<!-- <view class="gift-btn">
					<text class="gift-btn-btn" @click="goPage('/pages/users/user_get_coupon/index')">去领取</text>
				</view> -->

			</view>
			<!-- @confirm="dialogConfirm" -->
			<view class="gift-wrap " v-if="false"
				:style="[{backgroundImage:'url(' + comApi+'crmebimage/public/maintain/2023/11/27/7c948479d023466a856ba6143ce4d9a0a6fjgq2hq4.png' + ')' }]">
				<view class="gift-msg">
					<view class="gift-msg-left">新人送
						<text class="gift-msg-left-num">200元</text>
					</view>
					<view class="gift-msg-right">认养优惠券</view>
				</view>
				<view class="gift-btn">
					<text class="gift-btn-btn" @click="goPage('/pages/users/user_get_coupon/index')">去领取</text>
				</view>

			</view>
			<view class="gift-close" @click="this.$refs.giftPup.close()">
				<image src="@/static/images/poster-close.png" mode=""></image>
			</view>
		</uni-popup>


		<liu-pageTab-bar index='0' :activeColor="'#333'"></liu-pageTab-bar>
		<uni-popup ref="addPeplePup" type="center" :is-mask-click='false'>
			<view class="safeguardPup-wrap">

				<view class="safeguardPup-head safeguardPup-head1 dis">
					<view class="">

					</view>
					<view class="safeguardPup-head-center">您的好友赠送您一个共富认养大礼包,请点击领取</view>
					<view class="safeguardPup-head-right" @click="closeaddPeplePup">
						<image src="@/static/com/icon_close.png" mode=""></image>
					</view>
				</view>
				<view class="safeguardPup-msg dis">
					<uni-forms ref="baseForm">
						<uni-forms-item label="转赠送人" name="name" :labelWidth='90'>
							<uni-easyinput v-model="phone" placeholder="请输入转赠人手机号后四位" />
						</uni-forms-item>

					</uni-forms>

					<view class="safeguardPup-btn">
						<view @click="closeaddPeplePup">取消</view>
						<view class="safeguardPup-btn-s" @click="addPepleBtn()">确定</view>
					</view>

				</view>

			</view>

		</uni-popup>
		<home></home>
	</view>

</template>

<script>
	import home from '@/components/home/index.vue'
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		getTransOrderGet
	} from '@/api/togeterRich/order.js'
	import {
		getIndexAdPage
	} from '@/api/togeterRich/index.js'
	import {
		HTTP_ADMIN_URL,
		HTTP_REQUEST_URL,
		HEADER,
		TOKENNAME,
		HEADERPARAMS
	} from '@/config/app';
	import qqmapsdk from '../../js_sdk/qqmap-wx-jssdk.js'
	const QQMapWX = new qqmapsdk({
		key: '847ee78528aa725de0c1699ccf34a419' //你的key
	});
	import hotList from "@/pages/index/components/hotList.vue"
	import fosterList from "@/pages/index/components/fosterList.vue"
	import navbar from '@/components/navbar.vue';
	import Auth from '@/libs/wechat';
	import Cache from '../../utils/cache';

	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	let app = getApp();
	import {
		getIndexData,
		getCoupons,
		setCouponReceive
	} from '@/api/api.js';
	// #ifdef MP-WEIXIN
	import {
		getTemlIds
	} from '@/api/api.js';
	// import {
	// 	SUBSCRIBE_MESSAGE,
	// 	TIPS_KEY
	// } from '@/config/cache';
	// #endif
	// #ifdef H5  
	import {
		follow
	} from '@/api/public.js';
	// #endif
	import {
		getShare
	} from '@/api/public.js';
	import a_seckill from './components/a_seckill';
	import b_combination from './components/b_combination';
	import c_bargain from './components/c_bargain';
	import goodList from '@/components/goodList';
	import promotionGood from '@/components/promotionGood';
	import couponWindow from '@/components/couponWindow';
	import ClipboardJS from "@/plugin/clipboard/clipboard.js";
	import {
		goShopDetail
	} from '@/libs/order.js'
	import {
		mapGetters
	} from "vuex";
	import tabNav from '@/components/tabNav.vue'
	import countDown from '@/components/countDown';
	import {
		getCategoryList,
		getProductslist,
		getProductHot,

	} from '@/api/store.js';
	// import {
	// 	setVisit
	// } from '@/api/user.js'
	import recommend from '@/components/recommend';
	// #ifdef MP
	import authorize from '@/components/Authorize';
	// #endif
	import {
		silenceBindingSpread
	} from '@/utils';
	// #ifndef MP
	import {
		kefuConfig
	} from "@/api/public";
	import {
		getWechatConfig
	} from "@/api/public";
	// #endif
	import Loading from '@/components/Loading/index.vue';
	const arrTemp = ["beforePay", "afterPay", "refundApply", "beforeRecharge", "createBargain", "pink"];
	export default {
		computed: mapGetters(['uid']),
		components: {
			hotList,
			fosterList,
			navbar,
			tabNav,
			goodList,
			promotionGood,
			couponWindow,
			countDown,
			a_seckill,
			b_combination,
			c_bargain,
			recommend,
			// #ifdef MP
			authorize,
			// #endif
			Loading,
			home
		},
		data() {
			return {
				// let url = ''
				// uni.navigateTo({
				// 	url: '/pagesA/web/webview?url=' + url,
				// })
				bannerList: [
				],
				phone: '',
				menu: [{
						name: "亲自研学",

						img: '../../static/index/icon_cgyy.png',
						url: '/pagesA/childStudy/index'
					},
					{
						name: "社群团购",
						img: '../../static/index/icon_cgyy.png',
						url: '/pagesA/groupPurchase/index'
					},
					{
						name: "美丽经济",
						img: '../../static/index/icon_cgyy.png',
						url: '/pagesA/BeautifulEconomy/index'
					},
					{
						name: "精品线路",
						img: '../../static/index/icon_cgyy.png',
						url: '/pagesA/qualityRoutes/index'
					},
					{
						name: "场馆预约",
						img: '../../static/index/icon_cgyy.png',
						url: '/pagesA/venueReservation/index'
					},
					{
						name: "限时抢购",
						img: '../../static/index/icon_xsqg.png',
						url: '/pages/activity/goods_seckill/index'
					},
					{
						img: 'icon_xxzx.png',

						name: '善治积分',
						url: '/pagesA/extended/index',

					},
					{
						img: 'icon_zzyy.png',
						name: '中医预约',
						url: '/pagesA/hospital/info',

					},

				],
				hotAdoptionPackageList: [],
				descTxtList: [],
				coutBj: '',
				comApi: '',
				nowTimeList: [],
				weatherData: '',
				lacationCity: "嘉兴市",
				lacationData: {},
				locationPup: false,
				loaded: false,
				loading: false,
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false, //是否隐藏授权
				statusBarHeight: statusBarHeight,
				navIndex: 0,
				navTop: [],
				followUrl: "",
				followHid: true,
				followCode: false,
				logoUrl: "",
				
				imgUrls: [],
				itemNew: [],
				menus: [],
				bastInfo: '',
				fastInfo: '',
				fastList: [],
				firstInfo: '',
				salesInfo: '',
				indicatorDots: false,
				circular: true,
				autoplay: true,
				interval: 3000,
				duration: 500,
				window: false,
				iShidden: false,
				navH: "",
				newGoodsBananr: '',
				couponList: [],
				liveList: [],
				hotList: [{
					pic: '/static/images/hot_001.png'
				}, {
					pic: '/static/images/hot_002.png'
				}, {
					pic: '/static/images/hot_003.png'
				}],
				ProductNavindex: 0,
				marTop: 0,
				childID: 0,
				loadend: false,
				loadTitle: '加载更多',
				sortProduct: [],
				where: {
					cid: 0,
					page: 1,
					limit: 10,
				},
				is_switch: true,
				hotPage: 1,
				hotLimit: 10,
				hotScroll: false,
				explosiveMoney: [],
				prodeuctTop: 0,
				searchH: 0,
				isFixed: false,
				goodType: 0, //精品推荐Type
				goodScroll: true, //精品推荐开关
				params: { //精品推荐分页
					page: 1,
					limit: 10,
				},
				tempArr: [], //精品推荐临时数组
				roll: [], // 新闻简报
				roll2: [], // 动态简报
				site_name: '', //首页title
				iSshowH: false,
				configApi: {}, //分享类容配置
				spikeList: [], // 秒杀
				point: '',
				privacyStatus: false, // 隐私政策是否同意过
				tabsScrollLeft: 0, // tabs当前偏移量
				scrollLeft: 0,
				lineColor: 'red',
				lineStyle: {}, // 下划线位置--动态甲酸
				listActive: 0, // 当前选中项

				duration: 0.2, // 下划线动画时长
				hotActivityInfoList: [],
				gift: [],
				canCode: '',
				shareMsg: {}
			}
		},
		watch: {
			ProductNavindex(newVal) { // 监听当前选中项
				this.setTabList()
			},
			listActive(newVal) { // 监听当前选中项
				this.setTabList()
			}
		},
		mounted() {

			console.log(this, '1')
			this.setTabList()

		},
		onLoad(query) {
			this.sys()

			this.getGift()
			var that = this;
			this.comApi = HTTP_ADMIN_URL
			this.coutBj = this.comApi +
				'/crmebimage/public/maintain/2024/03/25/5fe90356f614459ea555b506a9cdf2e7JHf55fusnu.png',

				// 获取系统信息
				uni.getSystemInfo({
					success(res) {
						that.$store.commit("SYSTEM_PLATFORM", res.platform);
					}
				});

			let self = this
			// #ifdef MP
			// 获取小程序头部高度
			this.navH = app.globalData.navHeight;
			let info = uni.createSelectorQuery().select(".mp-header");
			info.boundingClientRect(function(data) {
				self.marTop = data.height
				self.poTop = Number(data.height) + 84
			}).exec()
			// #endif
			// #ifndef MP
			this.navH = 0;
			// #endif
			// this.isLogin && silenceBindingSpread();
			// Promise.all([this.getAllCategory(), this.getIndexConfig()
			// 	// , this.setVisit()
			// ]);
			this.getIndexConfig();
			// #ifdef MP
			this.getTemlIds()
			// #endif


		},
		onShow() {
			let self = this
			// this.shareMsg = uni.getStorageSync("shareMsg")
			// if (this.shareMsg.shareStatus == true) {
			// 	this.$refs.addPeplePup.open()
			// 	this.canCode = this.shareMsg.shareCode

			// }
			// console.log(this.shareMsg, '2shareMsgshareMsgshareMsg')


			this.lacationData = uni.getStorageSync("location")
			this.weatherData = uni.getStorageSync("weatherData")
			if (!this.lacationData) {
				this.$refs.inputDialog.open()
			} else {
				this.regexAddressBean(this.lacationData.address)
			}
			// uni.setNavigationBarTitle({
			// 	title: self.site_name
			// })

		},

		methods: {
			
			closeaddPeplePup() {
				// this.shareMsg = {
				// 	shareCode: '点击取消，再扫一次',
				// 	shareStatus: false
				// }
				// uni.setStorageSync('shareMsg', this.shareMsg);
				this.$refs.addPeplePup.close()
			},

			// this.$refs.addPeplePup.open()

			regexAddressBean(address) {

				var regex = /^(北京市|天津市|重庆市|上海市|香港特别行政区|澳门特别行政区)/;

				var province = [];
				var addressBean = {
					province: null,
					country: null,
					city: null,
					address: null,
				};

				// console.log('address', address);
				// console.log('addressBean', addressBean);
				regex = /^(.*?[市]|.*?[州]|.*?地区|.*?特别行政区)(.*?[区]|.*?[市]|.*?[县])(.*?)$/g;
				var addxress = regex.exec(address);
				console.log('addxress', addxress);
				this.lacationCity = addxress[1]

				return addxress[1];

			},
			addPepleBtn() {
				var canCodes = uni.getStorageSync('canCode');
				let data = {
					code: this.phone,
					orderNo: canCodes
				}
				getTransOrderGet(data).then(res => {
					uni.setStorageSync('canCode', 'undefined');
					this.$refs.addPeplePup.close()
					uni.showModal({
						title: '领取成功',
						content: '恭喜您领取成功赠送礼包，请到我的-认养订单里查看',
						showCancel: true,
						cancelText: '知道了',
						confirmText: '去查看',
						success: res => {

							if (res.confirm) {
								uni.navigateTo({
									url: '/pagesB/fosterOrder/index?status=10'
								})
							}
						},
						fail: () => {},
						complete: () => {}
					});
				})


			},
			sys() {

				uni.hideLoading();
				let that = this
				// 获取当前页面栈
				const pages = getCurrentPages();
				// 获取当前页面对象
				const currentPage = pages[pages.length - 1];

				// 解码获取到的scene参数值：teamId=1&secret=SMhbE
				const scene = decodeURIComponent(currentPage.options.scene);
				console.log(scene, '这是什么呢？')
				// 如果获取到了链接的东西，那么直接调用弹框

				if (scene != 'undefined') {
					console.log("扫描走的")
					that.$refs.addPeplePup.open()
					uni.setStorageSync('canCode', scene);
					that.canCode = scene
				}
				var canCodes = uni.getStorageSync('canCode');
				console.log(canCodes); // 输出：Tom
				// console.log(canCodes)
				if (canCodes != 'undefined' && canCodes != '') {
					console.log("扫描之后走的")
					that.$refs.addPeplePup.open()
				}

			},
			getGift() {
				getIndexAdPage("1").then(res => {
					console.log(res, 'res')
					this.gift = res.data
					if (res.data.length != 0) {
						this.$refs.giftPup.open()
					}

				})

			},
			change(e) {
				console.log('当前点击的tabbar信息:', e)


			},
			
			// 跳转页面
			goPage(url, type) {

				if (type == 2) {
					uni.navigateTo({
						url: '/pagesA/web/webview?url=' + url,

					})
				} else {
					uni.navigateTo({
						url: url
					})

				}

			},
			getLocationBtn() {
				this.$refs.inputDialog.open()
			},
			dialogConfirm() {
				let that = this

				uni.getLocation({
					type: 'wgs84',
					altitude: true,
					geocode: true,
					success: function(res) {
						console.log(res, 'wiijihn')
						try {
							that.getAdrees(res)
							uni.setStorageSync('user_latitude', res.latitude);
							uni.setStorageSync('user_longitude', res.longitude);
						} catch {}
					},
					fail: function(res) {

						console.log(res, '来看看');

					},
				});
				// console.log("aquhbnu")
			},
			// 获取地理位置
			getAdrees(res) {
				let that = this
				uni.request({
					url: 'https://restapi.amap.com/v3/geocode/regeo',
					data: {
						key: 'a9fc867e335a57f1b97af16f235ca695',
						output: 'JSON',
						location: res.longitude + ',' + res.latitude
					},
					success: (res1) => {

						res.address = res1.data.regeocode.formatted_address
						uni.setStorageSync('location', res);
						uni.setStorageSync('locationData', res1.data.regeocode);
						this.regexAddressBean(res1.data.regeocode.formatted_address)

						this.getWearth(res1)
					},
					fail: (res) => {
						console.log(res)
					}
				})
			},
			getWearth(res) {
				let that = this

				uni.request({
					url: 'https://restapi.amap.com/v3/weather/weatherInfo',
					data: {
						key: 'a9fc867e335a57f1b97af16f235ca695',
						output: 'JSON',
						city: res.data.regeocode.addressComponent.adcode || "330119"
					},
					success(ress) {

						that.weatherData = ress.data.lives[0].weather + ress.data.lives[0].temperature + "℃"
						uni.setStorageSync('weatherData', ress.data.lives[0].weather + ress.data.lives[0]
							.temperature + "℃");
					}
				})
			},
			getCoupon: function(id, index) {
				let that = this;
				//领取优惠券
				setCouponReceive(id).then(function(res) {
					that.$set(that.couponList[index], 'isUse', true);

					that.$util.Tips({
						title: '领取成功'
					});
				}, function(res) {
					return that.$util.Tips({
						title: res
					});
				})
			},
			clickSort(index) {
				this.listActive = index
			},
			// scroll-view滑动事件
			scroll(e) {
				this.scrollLeft = e.detail.scrollLeft;
			},
			setTabList() {
				this.$nextTick(() => {
					//this.setLine()
					this.scrollIntoView()
				})
			},
			// 计算tabs位置
			scrollIntoView() { // item滚动
				let lineLeft = 0;
				this.getElementData('#tab_list', (data) => {
					let list = data[0]
					this.getElementData(`#tab_item`, (data) => {
						let el = data[this.listActive]
						lineLeft = el.width / 2 + (-list.left) + el.left - list.width / 2 - this.scrollLeft
						this.tabsScrollLeft = this.scrollLeft + lineLeft
					})
				})
			},
			//  计算下划线位置
			setLine() {
				let lineWidth = 0,
					lineLeft = 0
				this.getElementData(`#tab_item`, (data) => {
					let el = data[this.listActive]
					lineWidth = el.width / 2
					// lineLeft = el.width * (this.currentIndex + 0.5)  // 此种只能针对每个item长度一致的
					lineLeft = el.width / 2 + (-data[0].left) + el.left
					this.lineStyle = {
						width: `${lineWidth}px`,
						transform: `translateX(${lineLeft}px) translateX(-50%)`,
						transitionDuration: `${this.duration}s`
					};
				})
			},
			getElementData(el, callback) {
				uni.createSelectorQuery().in(this).selectAll(el).boundingClientRect().exec((data) => {
					callback(data[0]);
				});
			},
			xieyiApp() {
				uni.navigateTo({
					url: '/pages/users/web_page/index?webUel=https://admin.java.crmeb.net/useragreement/xieyi.html&title=协议内容'
				})
			},
			// #ifdef MP
			getTemlIds() {
				for (var i in arrTemp) {
					this.getTem(arrTemp[i]);
				}
			},
			getTem(data) {
				getTemlIds({
					type: data
				}).then(res => {
					if (res.data) {
						let arr = res.data.map((item) => {
							return item.tempId
						})
						wx.setStorageSync('tempID' + data, arr);
					}
				})
			},
			// #endif
			// 首页数据
			getIndexConfig: function() {
				let that = this;
				getIndexData().then(res => {
					// uni.setNavigationBarTitle({
					// 	title: '首页'
					// })
					that.$set(that, "logoUrl", res.data.logoUrl);
					that.$set(that, "site_name", '首页');
					that.$set(that, "bannerList", res.data.banner2);
					that.$set(that, "imgUrls", res.data.banner);
					that.$set(that, "menus", res.data.menus);
					uni.setStorageSync('menus', res.data.toolBar)
					that.$set(that, "nowTimeList", res.data.agriculturalData);
					that.$set(that, "hotActivityInfoList", res.data.hotActivityInfoList);

					that.$set(that, "roll", res.data.roll);
					that.$set(that, "roll2", res.data.roll2);
					that.$set(that, "descTxtList", res.data.descTxtList);
					that.$set(that, "hotAdoptionPackageList", res.data.hotAdoptionPackageList);

					that.$set(that, "roll", res.data.roll ? res.data.roll : []);
					// #ifdef H5
					that.$store.commit("SET_CHATURL", res.data.yzfUrl);
					Cache.set('chatUrl', res.data.yzfUrl);
					// #endif
					that.$set(that, "explosiveMoney", res.data.explosiveMoney);
					if (res.data.explosiveMoney) {
						that.goodType = res.data.explosiveMoney[0].type
					}

					// this.getGroomList();
					this.shareApi();
					this.getcouponList();
					// #ifdef H5
					// that.subscribe = res.data.subscribe;
					// #endif

				})
			},
			getcouponList() {
				let that = this;
				getCoupons({
					page: 1,
					limit: 6,
					position: 3
				}).then(res => {
					that.$set(that, "couponList", res.data);
					// 小程序判断用户是否授权；
					// #ifdef MP
					uni.getSetting({
						success(res) {
							if (!res.authSetting['scope.userInfo']) {
								that.window = that.couponList.length ? true : false;
							} else {
								that.window = false;
								that.iShidden = true;
							}
						}
					});
					// #endif
					// #ifndef MP
					// if (that.isLogin) {
					// 	that.window = false;
					// } else {
					// 	that.window = res.data.length ? true : false;
					// }
					// #endif
				}).catch(err => {
					return this.$util.Tips({
						title: err
					});
				});
			},
			shareApi: function() {
				getShare().then(res => {
					this.$set(this, 'configApi', res.data);
					// #ifdef H5
					this.setOpenShare(res.data);
					// #endif
				})
			},
			getChatUrL() {
				kefuConfig().then(res => {
					let data = res.data;
					this.$store.commit("SET_CHATURL", data.yzfUrl);
					Cache.set('chatUrl', data.yzfUrl);
				})
			},
			// 微信分享；
			setOpenShare: function(data) {
				let that = this;
				if (that.$wechat.isWeixin()) {
					let configAppMessage = {
						desc: data.synopsis,
						title: data.title,
						link: location.href,
						imgUrl: data.img
					};
					that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"],
						configAppMessage);
				}
			},
			// 授权关闭
			authColse: function(e) {
				this.isShowAuth = e
			},
			// 授权回调
			onLoadFun() {

			},
			// 首发新品切换
			ProductNavTab(item, index) {
				this.listActive = index
				this.goodType = item.type
				this.listActive = index
				this.ProductNavindex = index
				this.tempArr = []
				this.params.page = 1
				this.goodScroll = true
				let onloadH = true
				// this.getGroomList(onloadH)
			},
			// 首发新品详情
			goDetail(item) {
				goShopDetail(item, this.uid).then(res => {
					uni.navigateTo({
						url: `/pages/activity/goods_details/index?id=${item.id}`
					})
				})
				return;
				if (item.activityH5 && item.activityH5.type === "2" && !this.isLogin) {
					toLogin();

					this.shareMsg = {
						shareCode: this.canCode,
						shareStatus: true
					}
					// this.$refs.addPeplePup.open()
					uni.setStorageSync('shareMsg', this.shareMsg);
					// this.shareMsg = {
					// 	shareCode: '只跳一次',
					// 	shareStatus: false
					// }
					// console.log('wwww')
					// uni.setStorageSync('shareMsg', this.shareMsg);
				} else {
					goShopDetail(item, this.uid).then(res => {
						uni.navigateTo({
							url: `/pages/activity/goods_details/index?id=${item.id}`
						})
					})
				}
			},
			// 分类详情
			godDetail(item) {
				goShopDetail(item, this.uid).then(res => {
					uni.navigateTo({
						url: `/pages/activity/goods_details/index?id=${item.id}`
					})
				})
			},
			// 精品推荐
			// getGroomList(onloadH) {
			// 	this.loading = true
			// 	let type = this.goodType;
			// 	if (!this.goodScroll) return
			// 	if (onloadH) {
			// 		this.iSshowH = true
			// 	}
			// 	getGroomList(type, this.params).then(({
			// 		data
			// 	}) => {
			// 		this.iSshowH = false
			// 		this.loading = false
			// 		this.goodScroll = data.list.length >= this.params.limit
			// 		this.params.page++
			// 		this.tempArr = this.tempArr.concat(data.list)
			// 	})
			// },
			/**
			 * 获取我的推荐
			 */
			get_host_product: function() {
				let that = this;
				that.loading = true;

				if (that.hotScroll) return
				getProductHot(
					that.hotPage,
					that.hotLimit,
				).then(res => {
					that.hotPage++
					that.hotScroll = res.data.list.length < that.hotLimit
					that.hostProduct = that.hostProduct.concat(res.data.list)
				});
			},
		},
		mounted() {
			let self = this
			// #ifdef H5
			//self.getChatUrL();
			// 获取H5 搜索框高度
			let appSearchH = uni.createSelectorQuery().select(".serch-wrapper");
			appSearchH.boundingClientRect(function(data) {
				self.searchH = data.height
			}).exec()
			// #endif
		},
		/**
		 * 用户点击右上角分享
		 */
		// #ifdef MP
		onShareAppMessage: function() {
			return {
				title: this.configApi.title,
				imageUrl: this.configApi.img,
				desc: this.configApi.synopsis,
				path: '/pages/index/index'
			};
		},
		// #endif
		onReachBottom() {
			if (this.navIndex == 0) {
				// 首页加载更多
				if (this.params.page != 1) {
					// this.getGroomList();
				}
			} else {
				// 分类栏目加载更多
				if (this.sortProduct.length > 0) {
					//this.get_product_list();
				} else {
					// this.get_host_product();
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.secondaryColour{
		color: $maincolor!important;
	}
	.com-banner {
		border-radius: 20rpx;
		height: 200rpx;
		margin: 0 auto;

		.swiper {
			width: 100%;
			height: 100%;

			image {
				border-radius: 20rpx;
				width: 100%;
				height: 100%;
			}
		}
	}

	page {
		background: $maincolor !important;
	}

	.safeguardPup-wrap {
		.safeguardPup-msg {
			width: 80%;

			margin: 30rpx auto;
			justify-content: space-between;
			font-size: 28rpx;
			flex-direction: column;
			text-align: center;

			.safeguardPup-btn {
				width: 100%;

				display: flex;
				justify-content: space-around;
				align-items: center;

				.safeguardPup-btn-s {
					background: $maincolor;
					color: #fff;
				}

				view {
					padding: 10rpx 80rpx;
					border: 2rpx solid #999;
					border-radius: 100rpx;
				}
			}
		}

		.safeguardPup-head1 {
			justify-content: space-between;
			padding: 36rpx 36rpx 0 36rpx;

			image {
				width: 50rpx;
				height: 50rpx;
			}
		}

		width: 600rpx;
		/* height: 600rpx; */
		background: #fff;
		border-radius: 20rpx;
		padding: 20rpx 0;
	}

	.gift-close {
		width: 70rpx;
		height: 70rpx;
		transform-origin: 50% 50%;
		transform: rotate(180deg);
		margin: 26px auto auto auto;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.gift-wrap {
		background: #fff;
		text-align: center;
		border-radius: 20rpx;

		image {
			width: 100%;
			height: 100%;
		}

		.gift-btn {
			text-align: center;
			color: #000;
			height: 60rpx;

			.gift-btn-btn {
				background: $maincolor;
				border-radius: 100rpx;

			}
		}

		.gift-msg {
			padding-top: 60rpx;

			.gift-msg-left {
				font-size: 58rpx;

				.gift-msg-left-num {
					color: #FDED9E;
				}
			}

			.gift-msg-right {
				font-size: 44rpx;
			}
		}

		text-align: center;
		color: #fff;
		justify-content: space-between;
		flex-direction: column;
		width: 450rpx;
		display: flex;
		height: 726rpx;
		margin: 0 auto;


		background-size: 100% 100%;
	}

	.index-realTime {
		width: 100%;

		display: flex;
		flex-wrap: wrap;

		justify-content: space-between;

		.realTime-msg {
			width: 45%;
			margin: 12rpx;

			height: 124rpx;
			background: $secondary-colour;
			opacity: 0.1;
			border-radius: 10rpx;
			opacity: 1;
			justify-content: space-between;
			align-items: center;
			padding: 0 20rpx;

			.realTime-msg-left {
				font-size: 28rpx;

				.realTime-msg-left-bom {
					color:#fff;
				}
			}

			.realTime-msg-right {
				image {
					width: 70rpx;
					height: 70rpx;
				}
			}

		}
	}


	.com-tit {
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		image {
			width: 40rpx;
			height: 40rpx;
		}
	}

	.index-wrap {
		.index-foster {
			width: 100%;

		}

		.index-coupon {
			.index-coupon-view {
				white-space: nowrap;
				width: 680rpx;
			}

			width: 100%;
			height: 200rpx;

			.index-coupon-msg {
				background-size: 100% 100%;
				display: inline-block;
				// width: 80%;
				height: 180rpx;

				border-radius: 20rpx;
				opacity: 1;
				margin-right: 20px;
				padding: 0 30rpx;

				.index-coupon-msg-wrap {
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 100%;
					width: 510rpx;
					padding-right: 20rpx;

					.index-coupon-msg-bom {
						width: 30rpx;
						font-size: 28rpx;
						color: $maincolor;
						padding: 10rpx 0;
						writing-mode: vertical-lr;
						/*从左向右 从右向左是 writing-mode: vertical-rl;*/
						writing-mode: tb-lr;
						/*IE浏览器的从左向右 从右向左是 writing-mode: tb-rl；*/
					}

					.index-coupon-msg-center {
						.index-coupon-msg-center-up {
							font-size: 28rpx;
						}

						.index-coupon-msg-center-bom {
							font-size: 20rpx;
							background: #C1C1C1;
							border-radius: 100rpx;
							opacity: 1;
							padding: 0 20rpx;
							text-align: center;
							margin-top: 20rpx;
							color: #fff;
						}
					}

					.index-coupon-msg-left {
						color: #ffffff;

						.index-coupon-msg-left-up {
							font-size: 44rpx;
						}

						.index-coupon-msg-left-bom {
							font-size: 20rpx;
						}
					}
				}

			}
		}

		.index-menu {
			width: 100%;
			display: flex;
			flex-wrap: wrap;
			margin: 20rpx 0;

			.index-menu-msg {
				text {
					line-height: 60rpx;
				}

				width: 20%;
				align-items: center;
				margin: 15rpx;
				text-align: center;
				font-size: 24rpx;

				display:flex;
				flex-direction: column;
				justify-content: space-between;

				image {
					width: 80rpx;
					height: 80rpx;
				}
			}
		}

		.index-wrap-msg {
			position: relative;
			// position: absolute;
			top: -90rpx;
			height: 100%;
			background: #fff;

			border-radius: 100rpx 100rpx 0 0;

		}

		position: relative;
		width: 100%;

	}

	.getRich-des {

		width: 100%;
		// padding:0 40rpx ;
		display: flex;
		justify-content: space-between;

		.getRich-des-left {
			width: 340rpx;
			height: 220rpx;

			background: #EEEEEE;
			border-radius: 20rpx;
			opacity: 1;
			color: #333;

			.getRich-des-left-up {
				font-size: 32rpx;
			}

			.getRich-des-left-bom {
				font-size: 20rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 5;
				/* 限制在三行 */
				-webkit-box-orient: vertical;
			}
		}
	}

	.notice {

		display: flex;
		align-items: center;
		justify-content: space-evenly;
		width: 100%;
		/* margin: 60rpx 0 50rpx 0; */
		border-radius: 100rpx 100rpx 0 0;
		background-color: #fff;
		/* margin-bottom: 25rpx; */
		padding: 20px 0;

		.line {
			color: #CCCCCC;
		}

		.pic {
			width: 140rpx;
			height: 100rpx;

			padding-right: 20px;

			border-right: 1px solid;

			image {
				width: 100%;
				height: 100%;
				display: block !important;
			}
		}

		.swipers {
			.notice-tag {
				width: 30%;
				padding: 0 30rpx;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				opacity: 1;
				border: 1px solid $maincolor;
				color: $maincolor;
				font-size: 22rpx;
				margin-right: 20rpx;
				text-align: center;
			}

			.notice-msg {
				width: 70%;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				font-size: 26rpx;
			}

			width: 444rpx;
			overflow: hidden;

			swiper {
				height: 50rpx;
				width: 100%;
				overflow: hidden;
				font-size: 22rpx;
				color: #333333;
			}
		}

		.iconfont {
			color: #999999;
			font-size: 20rpx;
		}
	}

	.index-head {
		background: $maincolor;
		position: relative;

		.index-banner {
			// padding-top: 20rpx;
			line-height: 80rpx;
		}

		//设置轮播的指示点位置

		.swiper {

			height: 750rpx;
			width: 100%;

			image {

				height: 750rpx;
				width: 100%;
			}
		}

		.index-serch {
			position: absolute;
			z-index: 99999;
			width: 100%;
			// background: rgba(255, 255, 255, 0.4);
			margin: 8vh 0;
			padding: 6px 29rpx;
			justify-content: space-between;
			align-items: center;
			display: flex;
			// width: 80%;


			.index-serch-right {
				width: 80rpx;
				height: 80rpx;
				background: rgba(255, 255, 255, 0.4);
				border-radius: 50%;

				image {
					width: 100%;
					height: 100%;
					vertical-align: middle;
				}
			}

			.index-serch-left {
				background: rgba(255, 255, 255, 0.4);
				border-radius: 60px 60px 60px 60px;
				opacity: 1;
				display: flex;
				justify-content: space-between;

				border-radius: 100rpx;
				padding: 16rpx 30rpx;
				width: 60%;

				.index-serch-left-right {
					color: #fff;
					display: flex;
					align-items: 26rpx;
					justify-content: flex-end;
					align-items: center;
					width: 70rpx;
					font-size: 26rpx;
				}

				.index-serch-left-left {
					display: flex;
					align-self: center;

					image {
						width: 40rpx;
						height: 40rpx;
					}

					input {

						padding: 0 20rpx;

					}
				}
			}
		}


		background-size: 100% 100%;

		.head-left {
			// color: $maincolor;
			// background: rgba(255, 255, 255, 0.4);
			color: #fff;

			.head-left-up {
				font-size: 28rpx;
			}

			.head-left-down {
				font-size: 24rpx;
				display: flex;
				align-items: center;

				image {
					width: 30rpx;
					height: 30rpx;
					vertical-align: middle;
					margin: 0 10rpx;
				}
			}
		}
	}
</style>